<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>盒子1</div>
    <div>盒子2</div>
    <div>盒子3</div>
    <input type="text">
    <script>
        const div = document.querySelector('div')
        const divArr = document.querySelectorAll('div')
        const ipt = document.querySelector('input')
        setTimeout(() => {
            div.innerHTML = '疯狂星期四'
        }, 3000)
        setTimeout(() => {
            divArr[1].innerHTML = 'V我50'
        }, 5000)
        div.addEventListener('click', function() {
            this.style.color = '#f20'
            this.innerHTML = '🐔🐔🐔'
        })
        ipt.addEventListener('keydown', function() {
            // ipt.style.backgroundColor = 'Red'
        })
        ipt.addEventListener('input', function(e) {
            let email = this.value
            let regex = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
            if (!regex.test(email)) {
                this.style.backgroundColor = 'Red'
            } else {
                this.style.backgroundColor = 'Green'
            }

        })
    </script>
</body>

</html>